<?php
declare (strict_types = 1);

namespace app\user\service\teacher;

use app\common\exception\LogicException;
use app\common\service\BaseService;
use app\user\logic\teacher\{MaterialCategory, Material as MaterialLogic};
use think\facade\Request;

/**
 * 讲师课程接口类
 */
class Material extends BaseService
{

    /**
     * 添加素材分组
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-08
     * @return [type] [description]
     */
    public function createCategory()
    {
        $param = Request::post();
        $data  = app(MaterialCategory::class)->createCategory($param);

        return $this->parseToData($data, 1, '添加成功');
    }

    /**
     * 修改素材分组
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-08
     * @return [type] [description]
     */
    public function updateCategory()
    {
        $param = Request::post();
        $data  = app(MaterialCategory::class)->updateCategory($param);

        return $this->parseToData($data, 1, '修改成功');
    }

    /**
     * 删除素材分组
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-08
     * @return [type] [description]
     */
    public function deleteCategory()
    {
        $param = Request::delete();
        $data  = app(MaterialCategory::class)->deleteCategory($param);

        return $this->parseToData($data, 1, '删除成功');
    }

    /**
     * 获取素材分组，可包含默认和全部选项
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-07
     */
    public function getCategoryList()
    {
        $param = Request::get();
        $data  = app(MaterialCategory::class)->getCategoryList($param);

        return $this->parseToData($data, 1, '获取成功');
    }

    /**
     * 获取素材列表
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-07
     */
    public function getMaterialList()
    {
        $param = Request::get();
        $data  = app(MaterialLogic::class)->getMaterialList($param);

        return $this->parseToData($data, 1, '获取成功');
    }

    /**
     * 获取素材列表
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-07
     */
    public function addMaterial()
    {
        $param = Request::post();
        $data  = app(MaterialLogic::class)->addMaterial($param);

        return $this->parseToData($data, 1, '上传成功');
    }

    /**
     * 修改素材名称
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-17
     * @return [type] [description]
     */
    public function updateMaterialName()
    {
        $param = Request::put();
        $data  = app(MaterialLogic::class)->updateMaterialName($param);

        return $this->parseToData($data, 1, '修改成功');
    }

    /**
     * 修改素材所属分组
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-17
     * @return [type] [description]
     */
    public function updateMaterialCategory()
    {
        $param = Request::put();
        $data  = app(MaterialLogic::class)->updateMaterialCategory($param);

        return $this->parseToData($data, 1, '移动成功');
    }

    /**
     * 删除素材
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-17
     * @return [type] [description]
     */
    public function deleteMaterial()
    {
        $param = Request::delete();
        $data  = app(MaterialLogic::class)->deleteMaterial($param);

        return $this->parseToData($data, 1, '删除成功');
    }

    /**
     * 获取回收站数据
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date 2021-06-17
     * @return [type] [description]
     */
    public function getDeletedMaterial()
    {
        $param = Request::get();
        $data  = app(MaterialLogic::class)->getDeletedMaterial($param);

        return $this->parseToData($data, 1, '获取成功');
    }

}
